//
//  SecondViewController.m
//  QYBaseProject
//
//  Created by Dxc_iOS on 2018/7/18.
//  Copyright © 2018年 代星创. All rights reserved.
//

#import "QYSecondViewController.h"
#import "DXCCategory.h"
#import "MJRefreshGifHeader+CJKTRefresh.h"
#import "UIColor+CJKTExtention.h"
#import "UIView+CJKTCircleAngle.h"

#import "QYThirdViewController.h"
#import "QYWaterMarkViewViewController.h"
#import "UIView+HHAddSubviews.h"
#define RedColor [UIColor redColor]
#define BlueColor [UIColor blueColor]
#define BlackColor [UIColor blackColor]

#define SFONT(a) [UIFont systemFontOfSize:a]
@interface QYSecondViewController ()<UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>

@end

@implementation QYSecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UIButton *shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:shareBtn];
    shareBtn.frame = CGRectMake(100, 100, 100, 50);
    [shareBtn setTitle:@"分享" forState:UIControlStateNormal];
    shareBtn.backgroundColor = [UIColor blackColor];
    [shareBtn addTarget:self action:@selector(BtnClicked1) forControlEvents:UIControlEventTouchUpInside];
    [shareBtn qy_setCornerRadius:6];
    
    
//    MMKV示例
    
    MMKV *mmkv = [MMKV defaultMMKV];
    
    [mmkv setBool:YES forKey:@"bool"];
    BOOL bValue = [mmkv getBoolForKey:@"bool"];
    if (bValue) {
        NSLog(@"YES");
    }else{
        NSLog(@"NO");
    }
    
    [mmkv setInt32:-1024 forKey:@"int32"];
    int32_t iValue = [mmkv getInt32ForKey:@"int32"];
    NSLog(@"iValue = %d",iValue);
    
    [mmkv setObject:@"hello, mmkv" forKey:@"string"];
    NSString *str = [mmkv getObjectOfClass:NSString.class forKey:@"string"];
    NSLog(@"str = %@",str);
    
//  Maker示例
//    比较（使用Maker能减少一大部分代码量，并且更直观易懂）
    
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(30, 180, 150, 40);
    label.layer.cornerRadius = 10;
    label.layer.masksToBounds = YES;
    label.layer.borderColor = [MakerUntil mk_colorWithHexString:@"#C3342E"].CGColor;
    label.layer.borderWidth = 2;
    label.text = @"Center";
    label.textColor = [MakerUntil mk_colorWithHexString:@"#C3342E"];
    label.font = [UIFont systemFontOfSize:17 weight:0];
    label.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:label];
    
    
    UILabel *label2 = UILabel.maker
    .com_setup(self.view)
    .com_frame(30, 280, 150 ,40)
    .com_cornerRadius(10)
    .com_border(2, @"#C3342E")
    .com_backgroundColor(@"#F1F1F1")
    .lab_text(@"Center_Maker")
    .lab_textColor(@"#C3342E")
    .lab_font1(17)
    .lab_textAlignment(mk_Center);
    
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
    
    __weak typeof(self) weakSelf = self;
    
    UIScrollView *mainScrollView = UIScrollView.maker
    .com_setup(self.view)
    .com_frame(0, 0, screenWidth, screenHeight)
    .scr_contentSize(CGSizeMake(screenWidth, screenHeight + 100));
    
    UIImageView *cardView = UIImageView.maker
    .com_setup(mainScrollView)
    .com_frame(20, 20, screenWidth - 40, 450)
    .com_border(1.0, @"#F1F1F1")
    .com_cornerRadius(5.0)
    .com_contentMode(mk_vToFill)
    .com_userInterface(YES)
    .img_imageName(@"bartholomew_kuma");
    
    UIView *contentView = UIView.maker
    .com_setup(cardView)
    .com_frame(0, 300, screenWidth-40, 150)
    .com_backgroundColor2(@"#000000", 0.5);
    
    UILabel.maker
    .com_setup(contentView)
    .com_frame(10, 10, screenWidth-60, 50)
    .lab_text(@"バーソロミュー くま: 这个名字来自耶稣的十二门徒之一，Bartholemew。")
    .lab_lineBreakMode(mk_Char)
    .lab_numberOfSection(2)
    .lab_font1(15)
    .lab_textColor(@"#FFFFFF");
    
    UILabel.maker
    .com_setup(contentView)
    .com_frame(10, 70, screenWidth-40, 15)
    .lab_text(@"赏金：2亿9600万贝里")
    .lab_textColor(@"#EEEEEE")
    .lab_font1(13);
    
    
    UIButton.maker
    .com_setup(contentView)
    .com_frame(10, 105, (screenWidth-40)/2-15, 30)
    .com_backgroundColor(@"#F1F1F1")
    .com_border(1.0, [UIColor lightGrayColor])
    .com_cornerRadius(5.0)
    .btn_title(@"抓捕", mk_Normal)
    .btn_titleColor([UIColor lightGrayColor], mk_Normal)
    .btn_font1(13)
    .btn_actionBlock(mk_TouchUpInside, ^(id sender) {
        NSLog(@"抓捕");
    });
    
    UIButton.maker
    .com_setup(contentView)
    .com_frame((screenWidth-40)/2+5, 105, (screenWidth-40)/2-15, 30)
    .com_backgroundColor(@"#FF8802")
    .com_cornerRadius(5.0)
    .btn_title(@"放我走吧/(ㄒoㄒ)/~~", mk_Normal)
    .btn_titleColor(@"#FFFFFF", mk_Normal)
    .btn_font1(13)
    .btn_actionBlock(mk_TouchUpInside, ^(id sender) {
        QYThirdViewController *confirm = [[QYThirdViewController alloc] init];
        [weakSelf.navigationController pushViewController:confirm animated:YES];
    });
    

    UIView *textFieldView = UIView.maker
    .com_setup(mainScrollView)
    .com_frame(20, cardView.frame.origin.y + cardView.frame.size.height + 20, screenWidth - 40, 50)
    .com_backgroundColor(@"#F1F1F1");
    
    UITextField.maker
    .com_setup(textFieldView)
    .com_frame(10, 10, textFieldView.frame.size.width - 20, 30)
    .tf_style(mk_RoundedRect)
    .tf_font1(13)
    .tf_placeholder(@"测试TextField")
    .tf_delegate()
    .tf_maxLength(10)
    .tf_optionBlock(^(){
        NSLog(@"return");
    })
    .tf_changeBlock(^(NSString *text) {
        NSLog(@"%@", text);
    });
    
//   分类 快速添加视图
    
    [self.view hh_addLabel:^(UILabel *label) {
        label.text = @"路漫漫其修远兮，吾将上下而求索。";
        label.textColor = [UIColor redColor];
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentCenter;
    } constraints:^(MASConstraintMaker *make) {
        make.top.equalTo(textFieldView.mas_bottom).offset(50);
        make.centerX.equalTo(self.view);
    }];
    
    
    
    
    
}



//MARK: 点击事件

-(void)BtnClicked1{
    NSLog(@"点击");
    [self.navigationController pushViewController:[QYWaterMarkViewViewController new] animated:YES];
   
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
